Ext.define('AM.view.PositionView', {
		extend: 'Ext.grid.Panel',
		alias : 'widget.positionView',
		store : 'PositionStore',
		columnLines:true,
		selModel: {
	        injectCheckbox: 0,
	        mode: "SIMPLE"     //"SINGLE"/"SIMPLE"/"MULTI"
	     
   		 },
   		selType: "checkboxmodel",
    	dockedItems: [{
        xtype: 'pagingtoolbar',
        dock: 'bottom',
        store : 'PositionStore',
        displayInfo: true
        }],
		columns: [
			        { text: '序号', dataIndex: 'id',width:50,align:'center'},
			        { text: '等级', dataIndex: 'name', width:200,align:'center'},
			        { text: '绩效系数', dataIndex: 'coffer', width:200,align:'center'}
			        
			     ],
			   tbar: [
//					  { xtype: 'button',text: '增加',handler: addDepartment, icon: 'Ext/restful/images/add.png'
//					  },
					  { xtype: 'button', text: '修改',handler: editPosition,icon: 'Ext/restful/images/cog_edit.png'
					  }
//					  { xtype: 'button', text: '删除',handler: deleteDepartment,icon: 'Ext/restful/images/delete.png'
//					  }
					]
	
})
  function editPosition() {
   		 var grid=this.ownerCt.ownerCt;
		 var myform1= new Ext.form.Panel({

			        bodyPadding: 20,
			        labelWidth : 65,
			        items: [{   
					   			  xtype : "textfield",
					   			  allowBlank:false,
					   		      fieldLabel: '绩效系数',
					   			  labelAlign :"right",
							      name: 'coffer',
							      width:300
							},{
								  xtype : "textfield",
					   		      fieldLabel: '科室id',
					   			  labelAlign :"right",
							      name: 'id',
							      hidden : true 
							}]		        	
		
		 })
			var win = new Ext.Window({
				title : "修改",
				width : 350,
				height : 200,
				frame:true,
				layout:'fit',
				items : [ myform1
							],
				buttons : [{
							text : "确定",
							handler : function() {
								win.getComponent(0).getForm().submit({
											 url : 'employees_editPosition',
											 success : function() {
											 	
												Ext.Msg.alert('提示', '修改成功');
												win.close();
												grid.getStore().reload();
												grid.getSelectionModel().deselectAll();
											},
											failure : function() {
												Ext.Msg.alert('错误', '修改失败');
											},
											waitMsg : "请稍后，正在保存。。。。"
	
										});
							}
						}, {
							text : "重置",
							handler : function() {
								win.getComponent(0).getForm().reset();
							}
						}, {
							text : "取消",
							handler : function() {
								win.close();
							    grid.getSelectionModel().deselectAll();		
							}
						}]
			});
//		var grid=this.ownerCt.ownerCt;
		var selections = grid.getSelectionModel().getSelection();
						if(selections.length==0){
							Ext.MessageBox.alert("提示","请选择要编辑的一行！");
						}else if (selections.length > 1) {
							Ext.MessageBox.alert("提示", "请检查您是否选中了多行！");
							return;
						} else{
							var record = selections[0];
						//这里是修改操作的实现部分
							win.getComponent(0).getForm().loadRecord(record);
							win.show();
						}
	}
